<?php
//命名空间
namespace App\Http\Controllers\Admin;
//引入了request
use Illuminate\Http\Request;
//use App\Http\Controllers\Controller;
class TestController extends Controller{
    //代码空间
    public function login(){
        return view("user.login");
    }
    //0 references|0 overrides
    public function check(Request $request){
        $name=$request->input("name");
        $password=$request->input("password");
        $rule=[
            'name'=>'required',
            'password'=>'required'
        ];
        $message=[
            'name.required'=>'用户名不能为空',
            'password.required'=>'密码不能为空'
        ];
        $validator=validator::make($request->all(),$rule.$message);
        if($validator->fails()){
            foreach ($validator->getMessageBag()->toArray() as $v) {
                $mag=$v[0];
            }
            return $mag;
        }
        if($name!='admin'||$password!='123456'){
            return '用户密码不正确';
        }
        session((['user'=>['id'=>1,'name'=>'admin']]));
        return '登录成功';
    }
}